import createModulePage from "../../../components/modulepage/index";

import { KxAppSubModule} from "../submodule";

import { HttpTaskTraits } from "../traits/http";

import { GLOBAL_APP_CLS } from "../../../variable";

import { pageName, componentName, refName } from "./variable";

class Module extends KxAppSubModule {
    constructor(name) {
        super(name);
    }
    _template() {
        var self = this;
        return `<div class="${self._name}">
    <div ref="${refName}" class="action app-action">
    </div>  
    <h5>AUICustomComponents</h5>
    <div>存放customComponent类 底层调用Vue.component</div>        
    <h5>AUIAuios</h5>
    <div>基于fetch的http ajax lib</div>   
    <h5>AUICookie</h5>
    <div>存放 修改cookie</div>
    <h5>AUIDeepmerge</h5>    
    <div>object deepmerge</div>
    <h5>AUITooltip</h5>
    <div>全局tooltip控制</div>
    <h5>AUIValidate</h5>
    <div>全局表单验证</div>
</div>`;
    }   
    
    _traits(instance) {
        return [ 
            new HttpTaskTraits(instance, `private_${pageName}_traits`) 
        ]
    }

    _mounted() {        
        var self = this;         
        self[`private_${pageName}_traits`].init({
            onError: function (error) {
                if (self.$refs[refName]) {
                    window.app.onError(error)
                }
            }
        });

        setTimeout(function () {
            self.search();
        }, 0);

        window.AUIPrism.highlightAll();
    }
    _methods(instance) {
        return {
            search(page = 1) {
                var self = this;
            },
            onSearch(data) {
                var self = this;
                self.search();
            },
            onPageChange(page) {
                var self = this;
                self.search(page);
            }
        }
    }
    _data() {
        var ret = {};
        return ret;
    }  
}


window.AUICustomComponents.define(`kx-app-${pageName}-module`, Module);

export default createModulePage(
    `<kx-app-${pageName}-module></kx-app-${pageName}-module>`
);